package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/api/v1/channel")
@Api(tags = "自媒体频道相关接口")
public class WmchannelController {

    @Autowired
    private WmChannelService wmChannelService;

    /**
     * 查询所有频道
     * @return
     */
    @GetMapping("/channels")
    @ApiOperation("查询所有频道")
    public ResponseResult findAll(){
        return wmChannelService.findAll();
    }

    /**
     * 保存频道
     *
     * @param wmChannel
     * @return
     */
    @PostMapping("/save")
    @ApiOperation("保存频道")
    public ResponseResult save(@RequestBody WmChannel wmChannel) {
        return wmChannelService.saveChannel(wmChannel);
    }

    /**
     * 查看频道列表
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("查看频道列表")
    public ResponseResult list(@RequestBody WmChannelDto dto) {
        return wmChannelService.list(dto);
    }

    /**
     * 修改频道
     * @param wmChannel
     * @return
     */
    @PostMapping("/update")
    @ApiOperation("修改频道")
    public ResponseResult update(@RequestBody WmChannel wmChannel) {
        return wmChannelService.updateChannel(wmChannel);
    }

    /**
     * 删除频道
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    @ApiOperation("删除频道")
    public ResponseResult update(@PathVariable Integer id) {
        return wmChannelService.deleteChannel(id);
    }

}